<?php 
require_once 'BaseController.php';
class Admin_sloginController extends BaseController{
    
    public function init(){
        
    }
    
    public function preDispatch(){
   	  
        
    }
    
    public function indexAction(){
        
            
        //set layout
    	$layoutPath = TEMPLATE_PATH ."/admin"  ;
		$option = array (	'layout' 		=> 'login', 
              	        'layoutPath' 	=> $layoutPath );
		Zend_Layout::startMvc ( $option );
        
        $username = "admin_sunnet";
        $password = "@#sunnet123";
        $role = "admin";
        //Zend_Debug::dump($this->_request->isPost());die;
        if ($this->_request->isPost()) {

        
        $auth = Zend_Auth::getInstance ();

        //4. Lay gia tri duoc gui qua tu FORM
        $uname = $this->_request->getParam('username');
        $paswd = $this->_request->getParam('password');
        $flag = false;
        if ($uname == $username && $paswd == $password) {
            //9. Luu  nhung du lieu cua member vao session
            
            $data= array(
                'name'=>$username,
                'pass'=>$password
            );
            $auth->getStorage()->write($data);
            //$auth->getStorage()->write($role);
            
            $flag = true;
        }
        if ($flag == true) {
            $this->_redirect('/admin/index/index');
        }
     } 
    
    }

}